'use strict';

const Controller = require('egg').Controller;

class ArticleController extends Controller {
  async delete() {
    const { ctx, service } = this;
    ctx.body = await service.article.delete(ctx);
  }

  async getOnAsk() {
    const { ctx, app: { cache } } = this;
    let _cache = cache;
    if (!_cache) {
      _cache = ctx.app.cache = await ctx.service.article.randomAsk();
    }
    ctx.body = _cache;
  }
}

module.exports = ArticleController;
